feat(cua-driver-rs)(macos): enable Chromium/Electron AX trees (AXManualAccessibility) for get_window_state#1756
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds Chromium/Electron accessibility support to the macOS AX driver. A new ChangesChromium accessibility enablement
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…_window_state Chromium/Electron apps (Arc, VS Code, Electron shells) ship their web-content accessibility tree off and only build it once an assistive client requests it. Without enablement the first AX walk returns an empty/title-bar-only tree. Flip AXManualAccessibility (modern, side-effect-free) on the application root, falling back to AXEnhancedUserInterface when the modern attribute is unsupported. When the flip actually takes, let the asynchronously-built tree settle (~500ms run-loop pump) before walking. Cache per-pid so repeat snapshots skip the settle. Native Cocoa apps reject the attribute and pay no cost. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
df5ddd5 to
d9491d3
Compare
- Add 0.4.2: macOS 14 Sonoma SkyLight selector guard (#1782, #1503) and Chromium/Electron AX trees via AXManualAccessibility (#1756). - Fix the 0.3.6 entry, which described the permissions-status fix backwards: it now reports the driver's grants (via the daemon), not the caller's. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Problem
Chromium-based apps (Arc, VS Code, Electron shells) ship their web-content accessibility tree off and only build it once an assistive client requests it. Without enablement, the first
get_window_stateAX walk of such an app returns an empty / title-bar-only tree — the macOS/AX analog of the empty-tree symptom tracked in #1616 (VS Code exposing only its title-bar elements). With enablement the full tree materializes.Change
In
walk_tree's app-setup path (right afterAXUIElementCreateApplication(pid)):AXManualAccessibility = trueon the app root (the modern, side-effect-free opt-in). If the app reports the attribute unsupported (kAXErrorAttributeUnsupported/ -25205), fall back toAXEnhancedUserInterface = true(the legacy flag some Electron builds expose instead). Native Cocoa apps (Finder, Calculator, TextEdit) reject both — they take no further action.pump_run_loop_brieflyhelper) so the tree has time to materialize before the walk reads it.HashSet<pid>(guarded by aMutexin aOnceLock) records pids we've already enabled + settled. Repeat snapshots of the same app skip the settle; the tree is already built and stays built for the life of the process.The settle delay fires only when enablement actually flips an app from unsupported→supported, so apps that never needed it (every native Cocoa app) pay zero added latency.
Hard dependency
This is intentionally higher-risk and must land after the Phase 1 messaging-timeout PR. Enablement makes the tree bigger (fully materialized instead of empty/partial) — which is exactly why it depends on the per-element AX messaging timeout (so a wedged element fails fast rather than stalling the now-larger walk) plus the node cap to keep the materialized tree bounded. Shipping this without those bounds would trade "empty/partial" for "complete but potentially huge."
Test
cargo build --release -p cua-driverpasses.cargo test --no-run -p platform-macoscompiles cleanly (the crate's test binary has a pre-existing, unrelatedlibswift_Concurrency.dylibrpath issue at the run step only).Refs #1616
🤖 Generated with Claude Code
Summary by CodeRabbit